package cn.kgc.crowdfundingadminspringboot02.service;

import cn.kgc.crowdfundingadminspringboot02.mapper.MenuMapper;
import cn.kgc.crowdfundingadminspringboot02.pojo.Menu;
import cn.kgc.crowdfundingadminspringboot02.pojo.MenuExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MenuServiceimpl implements MenuService {
    @Resource
    MenuMapper menuMapper;

    @Override
    public List<Menu> getAll() {
        return menuMapper.selectByExample(null);
    }

    @Override
    public void saveMenu(Menu menu) {
        menuMapper.insert(menu);
    }

    @Override
    public Menu getMenuById(Integer id) {
        return menuMapper.selectByPrimaryKey(id);
    }

    @Override
    public void update(Menu menu) {
        menuMapper.updateByPrimaryKeySelective(menu);
    }

    @Override
    public void delete(Integer id) {
        MenuExample menuExample = new MenuExample();
        menuExample.createCriteria().andIdEqualTo(id);
        menuMapper.deleteByExample(menuExample);
    }


}
